var windowWidth = document.documentElement.clientWidth;

var windowHeight = document.documentElement.clientHeight;
     //浏览器中心点的横坐标
var centerX = windowWidth/2;
     //浏览器中心点的纵坐标
var centerY = windowHeight/2;

$("#xc div").each(function(){
     //随机生成横坐标
    var x = Math.random()*1000-400;
    x = Math.floor(x);
    x = centerX + x -100;
        //随机生成纵坐标
    var y = Math.random()*600-300;
    y = Math.floor(y);
    y = centerY + y - 100;

        //设置图片位置
    $(this).css("left",x+"px");
    $(this).css("top",y+"px");
    //随机生成一个角度
    var angle = Math.random()*40;
    angle = angle>20?angle+20:angle;
    angle-=30;
    angle = Math.floor(angle);
        //设置旋转
    $(this).css("transform","rotate("+angle+"deg)");



});

    $("#xc div a").fancybox();